import { Injectable } from '@angular/core';
import { Http } from '@angular/http';

@Injectable()
export class MyPacketService {
    //private lppUrl = 'http://localhost:3661';
    private lppUrl = 'http://lpp.arktao.com';
    private storeUrl = 'http://packetstore.arktao.com';

    constructor(private http: Http) { }
    //获取我的教案包列表
    GetMyPacketList(UserGuid): Promise<any> {
        return this.http.get(this.lppUrl + "/MyPacket/MyPacketList/" + UserGuid + "")
            .toPromise().then(res => { return res.json() })
    }
    //获取某个我的教案包
    GetMyPacket(MyPacketGuid): Promise<any> {
        return this.http.get(this.lppUrl + "/MyPacket/MyPacket/" + MyPacketGuid + "")
            .toPromise().then(res => { return res.json() })
    }
    //修改我的教案包
    PutMyPacket(data): Promise<any> {
        return this.http.put(this.lppUrl + "/MyPacket/MyPacket/",
            {
                MyPacketGuid: data.PK_MyPacketGuid,
                PacketName: data.PacketName,
                EnPacketName: data.EnPacketName,
                CoverUrl: data.CoverUrl,
                Publisher: data.Publisher
            })
            .toPromise().then(res => { return res.json() })
    }
    //移除我的教案包
    RemoveMyPacket(MyPacketGuid): Promise<any> {
        return this.http.delete(this.lppUrl + "/MyPacket/RemoveMyPacket/" + MyPacketGuid + "")
            .toPromise().then(res => { return res.json() })
    }
    //根据教案包模板Guid获取商店信息
    GetPacketStoreMsg(Packetguid): Promise<any> {
        return this.http.get(this.storeUrl + "/packet/PacketStoreMsg/" + Packetguid + "")
            .toPromise().then(res => { return res.json() })
    }
}